﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Search4.Web.View.MasterPage
{
    public class Layout : System.Web.UI.MasterPage
    {
        #region COMPONENTES
        public LinkButton lbtLogin{ get; set; }
        public LinkButton lbtPainel { get; set; }
        public Label lblWelcome { get; set; }
        public Label lblSeparador { get; set; }
        public Button btnSearch { get; set; }
        public TextBox tbxSearch { get; set; }
        public LinkButton lbtCadastro { get; set; }
        public LinkButton lbtLogout { get; set; }
        #endregion


        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            ConfigurarPagina();
        }

        private void ConfigurarPagina()
        {
            lbtLogin.Click += lbtLogin_Click;
            lbtPainel.Click += lbtPainel_Click;
            btnSearch.Click += btnSearch_Click;
            lbtLogout.Click += lbtLogout_Click;
        }

        void lbtLogout_Click(object sender, EventArgs e)
        {
            Session["USUARIO"] = null;
            Response.Redirect("/Cadastro/Login.aspx");
        }

        void btnSearch_Click(object sender, EventArgs e)
        {
            Response.Redirect(String.Concat("/Paginas/Consulta.aspx?params=", tbxSearch.Text));
        }

        void lbtPainel_Click(object sender, EventArgs e)
        {
            Response.Redirect("/Cadastro/Perfil.aspx");
        }

        void lbtLogin_Click(object sender, EventArgs e)
        {
            Response.Redirect("/Cadastro/Login.aspx");
        }
    }
}
